
#pragma once
#include <fstream>
#include <iostream>
#include <string>

#include "Common/Logger.h"
#include "Common/Types.h"
#include "FServer/MySQL/MySQLParserNodes.h"
#include "FServer/MySQL/MySQLStatement.h"

namespace keeper_server {
/// Forward declarations of classes
class Parser;
class Scanner;
class location;

class MySQLParser {
 public:
  MySQLParser(MySQLStatement& stmt);
  ~MySQLParser();

  int parse();
  int parse(std::string& str);
  int parse_file(std::string& path);

  void reset();
  char* create_char_string(const char* value) {
    auto len = strlen(value);
    char* tmp = new char[len + 1];
    memcpy(tmp, value, len);
    tmp[len] = '\0';
    return tmp;
  }
  void print_info() {
    for (auto name : tmp) {
      LOG_INFO("get:%s", name.c_str());
    }
    for (auto expr : _exprs) {
      expr->print_info();
    }
  }

 private:
  Scanner* scanner_;
  Parser* parser_;
  location* location_;
  int error_;
  std::vector<String> tmp;
  std::vector<BaseExpressionPtr> _exprs;

  /// Allows Parser and Scanner to access private attributes
  /// of the Driver class
  friend class Parser;
  friend class Scanner;
};
}  // namespace keeper_server
